package com.douwong.student.activity;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;

import com.douwong.student.R;
import com.douwong.student.application.BaseApplication;
import com.douwong.student.base.BaseActivity;
import com.douwong.student.enums.E_CommandType;
import com.douwong.student.enums.E_Destination;
import com.douwong.student.socket.LTPServer;
import com.douwong.student.utils.NetUtils;
import com.douwong.student.utils.ToastUtils;

/**
 * @autor yichao
 * @time 2017/7/616:34
 * @des 抢答
 */

public class ResponderActivity extends BaseActivity {

    private Button mButton;

    public static void startActivity(Context context){
    Intent intent=new Intent(context,ResponderActivity.class);
    context.startActivity(intent);
}
    @Override
    protected void initView() {
        setContentView(R.layout.act_responder);
        mButton = (Button) findViewById(R.id.button_responder);
    }

    @Override
    protected void initEvent() {
        super.initEvent();
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!NetUtils.NetwrokIsUseful(ResponderActivity.this)){
                    ToastUtils.makeText(ResponderActivity.this,"请检查网络");
                    return;
                }
                if (BaseApplication.sTeacherOnline==null || !BaseApplication.isLoginClass){
                    ToastUtils.makeText(ResponderActivity.this,"请加入课堂");
                    finish();
                    return;
                }
                LTPServer.createInstance(ResponderActivity.this).sendMsg(true,
                        E_CommandType.answer,
                        E_Destination.teacher,new int[]{BaseApplication.sTeacherOnline.teacher.teacherId});

                         finish();
            }
        });
    }
}
